<html>
	<head>
		<#assign path="${request.contextPath}"/>
		<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no">
		<meta charset="utf-8"/>
		<#include "include/lib.ftl"/>
		<style>
			h1{text-align:center;}
			.totalDataText{font-size:16px;text-align:center;}
			#title{margin-bottom:20px;}
			#add{width:100%;margin-top:15px;}
			#onn{margin-top:10%;display:none;}
		</style>
	</head>
	<body>
	<#include "include/header.ftl"/>
		<div id="dialog" class="col-md-3 col-md-offset-9 col-sm-12"></div>
		<div id="onn" class="" style="">
			<div id="cen">
				<div class="col-md-4 col-sm-0"></div>
				<div id="con" class="col-md-4 col-sm-12">
					<div class="col-md-2 col-sm-0"></div>
					<div class="col-md-8 col-sm-12">
					<h1>新增类型</h1>
					<form role="form">
						<!-- 把表单控件放在这个.form-group的里面，可以获取最佳间距 -->
						<div class="form-group">
							<label for="status">状态:</label>
							<select id="status" name="status" class="form-control">
								<option value="1">支出</option>
								<option value="0">收入</option>
							</select>
						</div>
						<div class="form-group">
							<label for="title">类型:</label>
							<input type="text" name="typeName" class="form-control" id="typeName" placeholder="请输入类型名称"/>
						</div>
						<div class="submit">
							<a id="add" class="btn btn-primary">增&nbsp;&nbsp;加</a>
						</div>
					</form>
					</div>
					<div class="col-md-2 col-sm-0"></div>
				</div>
				<div class="col-md-4 col-sm-0"></div>
			</div>
		</div>
	</body>
	<script>
		
		$(function(){
			$("#onn").css("display","block");
			var t = setTimeout(addAni,100);
		});
		
		function addAni(){
			$("#onn").addClass("animated bounceInDown");
		}
	
		$("#add").click(function(){
			var title = $("#typeName").val().trim();
			var status = $("#status").val();
			if(title.length == 0){
				var dialog = new Dialog("请输入类型名称","warning");
				dialog.obj = "#dialog";
				dialog.show();
				return;
			}else{
				$.ajax({
					url:"${path}/data/addType.ajax",
					type:"post",
					dataType:"json",
					data:{typeName:title,status:status},
					success:function(data){
						if("SUCCESS" == data.result){
							$("#typeName").val("");
							var dialog = new Dialog("新增类型成功");
							dialog.obj = "#dialog";
							dialog.show();
						}else{
							var dialog = new Dialog(data.msg,"warning");
							dialog.obj = "#dialog";
							dialog.show();
						}
					},
					error:function(e){
						var dialog = new Dialog("错误:增加类型失败","danger")
						dialog.obj = "#dialog";
						dialog.show();
					}
				});
			}
		});
		$(".menu_addType").addClass("active");
	</script>
</html>